package com.privated.work.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.privated.work.entity.BusinessFinal;
import com.privated.work.dao.BusinessFinalDao;
import com.privated.work.service.BusinessFinalService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/**
 * (BusinessFinal)表服务实现类
 *
 * @author makejava
 * @since 2021-01-15 00:51:20
 */
@Service("businessFinalService")
public class BusinessFinalServiceImpl extends ServiceImpl<BusinessFinalDao,BusinessFinal> implements BusinessFinalService {
    @Resource
    private BusinessFinalDao businessFinalDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public BusinessFinal queryById(Long id) {
        return this.businessFinalDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<BusinessFinal> queryAllByLimit(int offset, int limit) {
        return this.businessFinalDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param businessFinal 实例对象
     * @return 实例对象
     */
    @Override
    public BusinessFinal insert(BusinessFinal businessFinal) {
        this.businessFinalDao.insert(businessFinal);
        return businessFinal;
    }

    /**
     * 修改数据
     *
     * @param businessFinal 实例对象
     * @return 实例对象
     */
    @Override
    public BusinessFinal update(BusinessFinal businessFinal) {
        this.businessFinalDao.update(businessFinal);
        return this.queryById(businessFinal.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.businessFinalDao.deleteById(id) > 0;
    }

    @Override
    public List<BusinessFinal> queryAll(QueryWrapper queryWrapper) {
        return businessFinalDao.selectList(queryWrapper);
    }

    @Override
    public void deleteAll() {
        businessFinalDao.delete(null);
    }
}